package com.ygo.feihua;


import android.graphics.*;
import android.graphics.drawable.*;
import com.file.zip.*;
import com.ygo.feihua.*;
import java.io.*;
import android.content.*;
import com.ygo.feihua.util.*;

public  class CardIm
{
		String km;

		Gongju gj;
		Context context;
	public CardIm (Context context,String km){
			this.km=km;
			this.context=context;
			gj=Gongju.getdx(context);
		}
		
	public interface onkt{
		void onc(String km,Bitmap bt);
	}
	
		onkt ono;
		public void setktt(onkt on){
			ono=on;

			new Thread(new Runnable(){

					@Override
					public void run()
					{
						//ImageView im=(ImageView) gr.findViewWithTag(km);
						//Message me=new Message();

						Bitmap bt= BitmapFactory.decodeResource(context.getResources(), R.drawable.unknown);
						File ff=new File(SharedPreferenceUtil.getYgopath()+"pics/"+km+".jpg");
						if(ff.exists()){
							bt=BitmapFactory.decodeFile(SharedPreferenceUtil.getYgopath()+"pics/"+km+".jpg");

							/*me.obj=new Object[]{im,bt};
							 me.what=8;
							 handler.sendMessage(me);*/
							ono.onc(km,bt);
						}else{
							try
							{
								ZipFile zip=new ZipFile(SharedPreferenceUtil.getYgopath() + "pics.zip");
								if(zip!=null){
									ZipEntry ze=zip.getEntry("pics/"+km+".jpg");
									if(ze!=null){
										bt=new BitmapDrawable(zip.getInputStream(ze)).getBitmap();
										ono.onc(km,bt);		
									}else{
										ono.onc(km,bt);				
									}
								}else{
									ono.onc(km,bt);
								}
							}
							catch (IOException e)
							{
								ono.onc(km,bt);
							}
						}
						// TODO: Implement this method
					}
				}).start();


		};

	}
	
	
	
